package com.bingarchive;

import java.net.URL;
import java.util.Date;

import android.util.Log;

class BingContact extends AbstractContact {

	private static final String BING_URL = "http://www.bing.com/HPImageArchive.aspx?format=xml&idx=%d&n=1&mkt=zh-CN";
	private static final String IMAGE_URL = "http://www.bing.com/az/hprichbg/rb/%i";

	public static String ReadXML(Record rcInfo) {
		Log.d("Kangsj", "Bing ReadXML Start : " + rcInfo.mstDate);

		Date dt = new Date();
		long aa = dt.getTime();
		long bb = rcInfo.mdtDate.getTime();
		long ln = PublicUtil.GetDay(dt) - PublicUtil.GetDay(rcInfo.mdtDate);

		String _stBingUrl = BING_URL.replace("%d", "" + ln);

		String _stXML = ReadXML(_stBingUrl);
		
		Log.d("Kangsj", "Bing ReadXML End : " + _stXML);
		return _stXML;
	}

	public static byte[] ReadImage(String stName) throws Exception {
		URL _url = new URL(IMAGE_URL.replace("%i", stName));
		return ReadFile(_url);
	}
}
